package com.house.rent.ui.adapter;

import android.content.Context;

import com.house.rent.R;
import com.house.rent.entity.HouseEntity;

/**
 * @author neo.duan
 * @date 2019-09-19 20:47
 * @desc 请输入文件描述
 */
public class HouseAdapter extends XBaseAdapter<HouseEntity> {

    public HouseAdapter(Context context) {
        super(context);
    }

    @Override
    protected int getLayoutResId(int viewType) {
        return R.layout.item_home;
    }

    @Override
    protected void convert(XBaseViewHolder helper, HouseEntity entity) {
        /*****图片*****/
        String housePhoto = entity.getHousePhoto();
        String[] split = housePhoto.split(",");
        if (split.length > 0) {
            helper.setImageUrl(R.id.iv_house_itm_img, "data:mime/type;base64," + split[0]);
        } else {
            helper.setImageResource(R.id.iv_house_itm_img, R.mipmap.ic_exmple);
        }

        /*****小区名称*******/
        helper.setText(R.id.tv_house_item_name, entity.getCommunityName());

        /*****房屋描述:10平|3室1厅1卫*******/
        StringBuilder builder = new StringBuilder();
        builder.append(entity.getSize() + "㎡").append(" | ");
        builder.append(entity.getApartment()).append(" | ");
        builder.append(entity.getFloor() + "楼");
        helper.setText(R.id.tv_house_item_desc, builder.toString());

        /*****租金*******/
        helper.setText(R.id.tv_house_item_price, entity.getCeilingPrice() + " 元/月");
    }
}
